class PrivateController < ApplicationController
  before_filter :login_required
  #layout "private/menu"

  def sub_layout
    "private/menu"
  end

  def show
    @page_title + " - Mina sidor"
    @user = session[:user]
  end

  def category_subscription_edit
    @category_subscription = CategorySubscription.find(params[:id])
    render :partial => "category_subscription_edit"
  end

  def category_subscription_save
    @category_subscription = CategorySubscription.find(params[:id])
    @category_subscription.keywords = params[:keywords]
    @category_subscription.save
    render :partial => "category_subscription_view", :locals => { :category_subscription => @category_subscription }
  end

  def category_subscription_remove
    CategorySubscription.delete(params[:id])
    @category_subscriptions = CategorySubscription.find_all_by_user_id session[:user].id
    @category_id = params[:id]
    #render :nothing => true
  end

  def ad_subscription_remove
    AdSubscription.delete(params[:id])
    @ad_subscriptions = AdSubscription.find_all_by_user_id session[:user].id
    @ad_id = params[:id]
    #render :nothing => true
  end

  def details_edit
    user = User.find(params[:id])
    render :partial => "details_edit"
  end

  def details_view
    user = User.find(params[:id])
    render :partial => "details_view"
  end

  def details_save
    user = User.update(params[:user][:id], params[:user])
    render :partial => "details_view"
  end

  def current
    render :partial => "current"
  end

  def details
    render :partial => "details"
  end

  def purchase
    render :partial => "purchase"
  end

  def sales
    render :partial => "sales"
  end

  def sales_edit
    redirect_to :controller => "sell", :action => "edit", :id => params[:id]
  end

  def sales_ad_view
    redirect_to :controller => "ad", :action => "view_minimal", :id => params[:id]
  end

  def sales_edit_cancel
    render :nothing => true
  end

  def ad_view
    ad = Ad.find(params[:id])
    render :partial => "sales_view", :locals => { :ad => ad }
  end

  def judgements
    render :partial => "judgements"
  end
end
